package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.domain.Activity;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.service.IActivityService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * \* User: chy
 * \* Date: 2025/10/11  9:55
 * \* Description:
 * \
 */
@RestController
@RequestMapping("/operation/activity")
public class ActivityController {

    @Resource
    private IActivityService activityService;
    /**
     * 后台端查询活动列表
     * @param reqDTO
     * @return
     */
    @GetMapping("/page")
    public PageResult<Activity> page(ActivityQueryForPageReqDTO reqDTO) {
      return   activityService.queryActivityList(reqDTO);
    }
    /**
     * 后台端保存活动
     * @param reqDTO
     */
    @PostMapping("/save")
    public void save(@RequestBody ActivitySaveReqDTO reqDTO) {
        activityService.saveActivity(reqDTO);
    }
    /**
     * 后台端根据id查询活动详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Activity getActivity(@PathVariable Long id) {
        return activityService.getById(id);
    }
    /**
     * 后台端更新活动
     * @param activity
     */
    @PutMapping("/update")
    public void update(@RequestBody Activity activity) {
        activityService.updateById(activity);
    }
    /**
     * 后台端撤销活动
     * @param id
     */
    @PostMapping("/revoke/{id}")
    public void revokeActivity(@PathVariable Long id) {
        activityService.revokeActivity(id);
    }

}
